import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import fire from '@dfeidao/atom-web/msg/fire';

import get from '@dfeidao/atom-web/local/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';


export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// todo
	const knowledge_name = get(fd, 'knowledge_name');
	const res = await nodejs<{ code: 0 | 1; result: string }>('knowledge-base/zj-000006/s001', {
		filter: {
			knowledge_name
		}
	});

	const flags = get(fd, 'flags');
	if (res.code === 1) {

		success("删除成功");
 const del = fd.data.node.querySelector<HTMLDivElement>('[data-id="dele"]');
			set_node_cls(del, 'display-n', true);
		if (flags === "2") {
			fire('zj-000001','a007');
		} if (flags === "3") {
			fire('zj-000001','a009');
		} if (flags === "4") {
			fire('zj-000001','a011');
		}
		return;

	} else {
		error("删除失败");
		return;
	}
}
